#include <iostream>

using namespace std;

class Date
{
private:
    int day, month, year;

public:
    Date();
    Date(int y, int m, int d);
    int getYear();
    int getMonth();
    int getDay();
    void setDate(int y, int m, int d);
    void Print();
    void addOneDay();
};

Date::Date()
{
    day = 0;
    month = 0;
    year = 0;
}

Date::Date(int y, int m, int d)
{
    day = d;
    month = m;
    year = y;
}

int Date::getYear()
{
    return year;
}

int Date::getMonth()
{
    return month;
}

int Date::getDay()
{
    return day;
}

void Date::setDate(int y, int m, int d)
{
    year = y;
    month = m;
    day = d;
}

void Date::Print()
{
    // cout << year << "/" << month << "/" << day << "/" << endl;
    printf("%d/%.2d/%.2d\n", year, month, day);
}

int isyear(int year)
{
    if (year % 100 != 0 && year % 4 == 0)
    {
        return 1;
    }
    if (year % 400 == 0)
    {
        return 1;
    }
    return 0;
}

void Date::addOneDay()
{
    int a[2][12] = {{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
                    {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}};
    day += 1;
    int sumday = 0;
    if (day > a[isyear(year)][month - 1])
    {
        sumday = day - a[isyear(year)][month - 1];
        day = sumday;
        month += 1;
    }
    if (month > 12)
    {
        month = 1;
        year += 1;
    }
}

int main()
{

    int count;
    cin >> count;
    for (int i = 0; i < count; i++)
    {
        Date p;
        int day, month, year;
        cin >> year >> month >> day;
        if (i & 2 == 1)
        {
            p = Date(year, month, day);
        }
        else
        {
            p.setDate(year, month, day);
        }
        cout << "Today is ";
        p.Print();
        cout << "Tomorrow is ";
        p.addOneDay();
        p.Print();
    }

    return 0;
}

/*

*/